#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  get_json_from_file.py
#       Author @  Huoty
#  Create date @  2016-04-21 11:31:37
#  Description @  
# *************************************************************

import json

def load_json_from_file(path):
    class JsonData(object):
        def __init__(self):
            super(JsonData, self).__init__()
            self.type = None
            self.data = None

        def __str__(self):
            return "JsonData(type: {}, data: {})".format(self.type, self.data)

        def __repr__(self):
            return self.__str__()

    jd = JsonData()
    with open(path, 'r') as f:
        try:
            data = json.load(f)
            jd.type = type(data)
            jd.data = data
        except Exception as e:
            jd.error = e

    return jd

# Script starts from here


